﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Yaml.Presentation.Parsing.TokenScanners {
    class StreamEndTokenScanner : TokenScanner {

        public StreamEndTokenScanner(Scanner scanner)
            : base(scanner) {
        }

        protected override bool CheckForToken() {
            return Reader.AtEnd || Reader.Peek() == '\0';
        }

        protected override void ScanForToken() {
            // Do nothing
        }

        protected override void AfterScan() {
            base.AfterScan();
            Scanner.UnwindAllIndent(Start);
            Scanner.State.SimpleKeys.Reset();
            Scanner.State.Done = true;
        }

        protected override Yaml.Presentation.Tokens.Token CreateToken() {
            return new Tokens.StreamEndToken(Start, End);
        }
    }
}
